#pragma once

#include "Approach.h"
#include "EphemWrapper.h"
#include "Integrator.h"
#include "RadaParamInterface.h"

class CApproachSearcher;

class TrajTrace: public CRefCountedAdapterBase
{
public:
	typedef CRefCounted<TrajTrace> Ptr;
public:
	TrajTrace()
	{
		memset(x, 0, sizeof(x));
		memset(v, 0, sizeof(v));
	}
	TrajTrace(const SBody &body)
	{
		memcpy(x, body.x, sizeof(x));
		memcpy(v, body.v, sizeof(v));
	}
	double x[3];
	double v[3];
};

typedef map<double, TrajTrace::Ptr> TimePosTrace;

class CTrajectory: public IForceInterface, public ISimpleIntegratorInterface
{
public:
	CTrajectory(CEphemWrapper::Ptr pEphem, CAsteroidOrbitParam::Ptr pAsteroidOrbitParam, double dStep);
	~CTrajectory();

	ListPtrApproachs Move(double dStartTime, double dEndTime, SBody &body, TimePosTrace * pTrace);
	bool SimpleMove(double start, double end, SBody &body);
protected:
	bool Force(int nv, double time, double *x, double *f);
protected:
	CEphemWrapper::Ptr	m_pEphem;
	CIntergator			m_Integrator;
	double				m_dStep;

	auto_ptr<CApproachSearcher> m_pAppSearcher;
};

